home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15693 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.3 KB  |  74 lines

  1. Path: news.compuserve.com!newsmaster
  2. From: Philippe Verdy <100105.3120@compuserve.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Visual C++ Help Needed - Serialize/ar problem
  5. Date: 7 Apr 1996 21:32:50 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4k9ca2$fl9@arl-news-svc-5.compuserve.com>
  8. NNTP-Posting-Host: ad04-110.compuserve.com
  9.  
  10. kirki@cts.com (kirk i.) s'Θcrit :
  11. > Hi...newbe to OOD and Visual C++ here.  I created an object that initiates 3 
  12. > edit boxes with the following intigers:
  13. >         int    m_seed = 0;
  14. >         int    m_popsize = 0;
  15. >         int    m_seed10 = m_seed +10;
  16. > all ...generally works well, in that the program window intiiates with the 
  17. > values 0, 0, and 10...so, the next step was to use the Serialize 
  18. > object/function to try to store and recall the three integer values after i 
  19. > change them.  so, i applied the following code:
  20. > // CGene2Doc serialization
  21. > void CGene2Doc::Serialize(CArchive& ar)
  22. > {
  23. >     if (ar.IsStoring())
  24. >     {
  25. >         //itoa(m_seed, sSeed, 10); 
  26. >         //itoa(m_popsize, sPopsize, 10); 
  27. >         //itoa(m_seed, sSeed10, 10); 
  28. >         
  29. >         ar << m_seed;
  30. >         ar << m_popsize;
  31. >         ar << m_seed10;
  32. >     }
  33. >     else
  34. >     {
  35. >         //ar >> sSeed;
  36. >         //ar >> sPopsize;
  37. >         //ar >> sSeed10;
  38. >         //m_seed = atoi(const char *sSeed);
  39. >         //m_popsize = atoi(sPopsize);
  40. >         //m_seed10 = atoi(sSeed10);
  41. >     }
  42. > }
  43. > when i compile, i get:
  44. > D:\Work\gene2\gene2doc.cpp
  45. > D:\Work\gene2\gene2doc.cpp(61) : error C2593: 'operator <<' is ambiguous
  46. > D:\Work\gene2\gene2doc.cpp(62) : error C2593: 'operator <<' is ambiguous
  47. > D:\Work\gene2\gene2doc.cpp(63) : error C2593: 'operator <<' is ambiguous
  48. > ...what did i do wrong here?
  49. > thanks in advance,
  50. > kirk
  51. I don't know Visual classes. But is CArchive your own class ?
  52. If so, did you define the << operators your self ?
  53. - If so, did you declare several << operators for different
  54. integer types ? If so did you forget the operator<<(int) ?
  55. - If not, what kind of << operators did you define ? If you
  56.   defined several << operators for different classes X
  57.   which have conversions "operator X(int)" or constructors
  58.   "X::X(int)", may be they conflict because several conversions
  59.   are possible ...
  60.   Check you code and remove unnecessary conversions, or add
  61.   an explicit CArchive::operator<<(const int) which will
  62.   bypass any problematic conversions...
  63.  
  64.